home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++
- Path: alexandria.organon.com!alexandria!jsa
- From: jsa@organon.com (Jon S Anthony)
- Subject: Re: C/C++ knocks the crap out of Ada
- In-Reply-To: ok@goanna.cs.rmit.EDU.AU's message of 19 Feb 1996 17:43:31 +1100
- Message-ID: <JSA.96Feb19192415@organon.com>
- Sender: news@organon.com (news)
- Organization: Organon Motives, Inc.
- References: <00001a73+00002504@msn.com> <4etcmm$lpd@nova.dimensional.com>
- <3114d8fb.5a455349@zesi.ruhr.de> <4f5h5t$f13@vixen.cso.uiuc.edu>
- <4g1bgf$l5@mailhub.scitec.com.au> <312515DF.7D3B@cmlj.demon.co.uk>
- <4g5sas$787@goanna.cs.rmit.EDU.AU> <4g966j$cr8@goanna.cs.rmit.EDU.AU>
- Date: Tue, 20 Feb 1996 00:24:15 GMT
-
- In article <4g966j$cr8@goanna.cs.rmit.EDU.AU> ok@goanna.cs.rmit.EDU.AU (Richard A. O'Keefe) writes:
-
- > Simple I/O:
- >
- > Step 1
- > Look it up in the manual
- > Step 2
- > Do what the Fine Manual says.
- >
- > *SIMPLE* I/O involves withing and using a couple of standard packages,
- > and then using Put, New_Line, Get, and Skip_Line. Pretty darned simple.
- > It has not been a problem for first-year students at this university.
- >
- > Ada does not support Fortran-style formatted I/O, nor PL/I style
- > formatted or pictured I/O (but see Interfaces.COBOL).
-
- For most naive (first time users) needs it is even simpler than this.
- Here, again, is a version in C and Ada of a simple first program:
-
- First, the Ada (14 lines):
-
- with Ada.Command_Line; use Ada.Command_Line;
- with Text_Io; use Text_Io;
-
- procedure X is
-
- begin
- Put_Line(
- "My name is " & Command_Name & ", I have" &
- Integer'Image(Argument_Count) & " arguments.");
- Put_Line("They are: ");
- for I in 1..Argument_Count loop
- Put_Line(" " & Argument(I));
- end loop;
- end;
-
- $ gnatmake $tests_wrk/x.adb
- $ x 1 2 3
- My name is x, I have 3 arguments.
- They are:
- 1
- 2
- 3
-
-
- Now the C (14 lines):
-
- #include <stdio.h>
-
- main (argc, argv)
- int argc;
- char *argv[];
-
- {
- int i;
-
- printf ("My name is %s, I have %d arguments \n", argv[0], argc-1);
- printf ("They are: \n");
- for (i = 1; i < argc; i++)
- printf(" %s\n", argv[i]);
- }
-
- $ gcc -o cx cx.c
- $ cx 1 2 3
- My name is cx, I have 3 arguments
- They are:
- 1
- 2
- 3
-
-
- /Jon
- --
- Jon Anthony
- Organon Motives, Inc.
- 1 Williston Road, Suite 4
- Belmont, MA 02178
-
- 617.484.3383
- jsa@organon.com
-
-